package com.bltec.emergency.mapper;

import com.bltec.emergency.model.ResShip;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ResShipMapper {
    //插入一条resShip记录
    @Insert("insert into res_ship (name,owner,department,type,state,registry,classification_society," +
            "create_by,create_time,enable) " +
            "values(#{name},#{owner},#{department},#{type},#{state},#{registry},#{classificationSociety},#{createBy},#{createTime},#{enable})")
    boolean insert(ResShip resShip);

    //通过id设置一条记录为不可用
    @Update("update res_ship set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update res_ship set name=#{name},owner=#{owner},department=#{department}," +
            "type=#{type},state=#{state},registry=#{registry},classification_society=#{classificationSociety},update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateResShipById(ResShip resShip);

    //查找符合id字段的记录
    @Select("select id,name,owner,department,type,state,registry,classification_society,create_by,create_time,update_by,update_time,enable" +
            " from res_ship where id =#{id} and enable=1")
    ResShip getResShipById(Long id);

    //查找所有记录
    @Select("select id,name,owner,department,type,state,registry,classification_society,create_by,create_time,update_by,update_time,enable" +
            " from res_ship where enable=1")
    List<ResShip> selectAll();
}